﻿Imports System.Collections.ObjectModel

Partial Public Class ImportWindow

    Private Class ImportedStation
        Inherits ViewModel.ViewModelBase

        Private _IsSelected As Boolean
        Public Property IsSelected() As Boolean
            Get
                Return _IsSelected
            End Get
            Set(ByVal value As Boolean)
                _IsSelected = value
                OnPropertyChanged("IsSelected")
            End Set
        End Property

        Private _Id As String
        Public Property Id() As String
            Get
                Return _Id
            End Get
            Set(ByVal value As String)
                _Id = value
                OnPropertyChanged("Id")
            End Set
        End Property

        Private _Name As String
        Public Property Name() As String
            Get
                Return _Name
            End Get
            Set(ByVal value As String)
                _Name = value
                OnPropertyChanged("Name")
            End Set
        End Property
    End Class

    Private Class ImportedWindowViewModel
        Inherits ViewModel.ViewModelBase

        Private _ImportedStations As New ObservableCollection(Of ImportedStation)
        Public ReadOnly Property ImportedStations() As ObservableCollection(Of ImportedStation)
            Get
                Return _ImportedStations
            End Get
        End Property




    End Class

    Private ViewModel As New ImportedWindowViewModel

    Public ReadOnly Property ResultStations() As IList(Of Model.Station)
        Get
            Dim list = New List(Of Model.Station)
            For Each s In ViewModel.ImportedStations
                Dim station = New Model.Station With { _
                    .Id = s.Id, _
                    .Name = s.Name}
                list.Add(station)
            Next
            Return list
        End Get
    End Property

    Public Sub New()

        ' この呼び出しは、Windows フォーム デザイナで必要です。
        InitializeComponent()

        ' InitializeComponent() 呼び出しの後で初期化を追加します。
        Me.DataContext = ViewModel
    End Sub

    Private Sub ImportWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Me.MoveToCenter()
    End Sub

    Private Sub OkButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Me.DialogResult = True
        Me.Close()
    End Sub

    Private Sub Cansel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Me.DialogResult = False
        Me.Close()
    End Sub
End Class
